//
//  SeasonTableViewCell.m
//  美食百科
//
//  Created by dllo on 16/1/28.
//  Copyright © 2016年 doll. All rights reserved.
//

#import "SeasonTableViewCell.h"
#import "ClassModel.h"
#import "UIImageView+WebCache.h"
@interface SeasonTableViewCell()
@property(nonatomic,retain)UIImageView *seasonImageview;
@property(nonatomic,retain)UILabel *seasonLabel;
@property(nonatomic,retain)UILabel *timeLabel;


@end
@implementation SeasonTableViewCell
- (void)dealloc
{   [_seasons release];
    [_seasonImageview release];
    [_seasonLabel release];
    [_timeLabel release];
    [super dealloc];
    
}
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        
        self.seasonImageview  = [[UIImageView alloc]init];
        [self.contentView addSubview:self.seasonImageview];
        [_seasonImageview release];
        
        self.seasonLabel  = [[UILabel alloc]init];
        self.seasonLabel.textColor = self.color;

        [self.contentView addSubview:self.seasonLabel];
        [_seasonLabel release];
    
        self.timeLabel  = [[UILabel alloc]init];
        self.timeLabel.font = [UIFont systemFontOfSize:14];
        self.timeLabel.textColor = self.color;
        [self.contentView addSubview:self.timeLabel];
        [_timeLabel release];
    
    }
    return self;
}


-(void)layoutSubviews
{
    [super layoutSubviews];
    self.seasonImageview.frame = CGRectMake(10, 10, self.bounds.size.height-20, self.bounds.size.height-20);
    
    self.seasonLabel.frame = CGRectMake(self.seasonImageview.frame.origin.x+self.seasonImageview.frame.size.width+10, self.seasonImageview.frame.origin.y, self.bounds.size.width/2, self.seasonImageview.frame.size.height/2);
    
    self.timeLabel.frame = CGRectMake(self.seasonLabel.frame.origin.x, self.seasonLabel.frame.origin.y+self.seasonLabel.frame.size.height,self.seasonLabel.frame.size.width , self.seasonLabel.frame.size.height);
    
}



-(void)setSeasons:(ClassModel *)seasons
{
    if (_seasons != seasons) {
        [_seasons release];
        _seasons = [seasons retain];
    }
    
    [self.seasonImageview sd_setImageWithURL:[NSURL URLWithString:seasons.image_url]placeholderImage:[UIImage imageNamed:@"u=1023456699,842778947&fm=21&gp=0"]];
    self.seasonLabel.text = seasons.name;
    self.timeLabel.text = seasons.descrip;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
